<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<title>祖龙娱乐  - BI系统</title>
	<link href="../../css/component.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../js/highcharts.js"></script>
	<script type="text/javascript" src="../../js/drawChart.js"></script>
</h:head>

<h:body>
	<ui:param name="bean" value="#{activityGameAction}" />
	
	<span class="pagetitle">游戏内分析 —— 活动分析</span>
	<p:separator />
	
	<!-- 右侧页面顶部查询部分 -->
	<h:form id="fsearch">
		<p:growl id="growl0" showDetail="true" sticky="true" />

        <h:outputLabel id="radioHide" value="#{bean.dateRadio}" style="visibility: hidden"/>
        <p:outputPanel id="customPanel" style="margin-bottom:10px">
            <p:selectOneRadio id="customRadio" value="#{bean.dateRadio}" layout="custom">
                <f:selectItem itemLabel="7" itemValue="7" />
                <f:selectItem itemLabel="15" itemValue="15" />
                <f:selectItem itemLabel="30" itemValue="30" />
                <f:selectItem itemLabel="0" itemValue="0" />
                <p:ajax update="radioHide customPanel" listener="#{bean.radioChange}"/>
            </p:selectOneRadio>

            <h:panelGrid id="opt" columns="14" cellpadding="5">
                <p:radioButton id="opt1" for="customRadio" itemIndex="0" />
                <h:outputLabel for="opt1" value="近7天" />
                <h:outputLabel />

                <p:radioButton id="opt2" for="customRadio" itemIndex="1" />
                <h:outputLabel for="opt2" value="近15天" />
                <h:outputLabel />

                <p:radioButton id="opt3" for="customRadio" itemIndex="2" />
                <h:outputLabel for="opt3" value="近30天" />
                <h:outputLabel />

                <p:radioButton id="opt4" for="customRadio" itemIndex="3" />
                <h:outputLabel for="opt4" value="自定义 开始时间" />
                <p:calendar value="#{bean.dateStart}" mode="popup" pattern="yyyy-MM-dd">
                </p:calendar>
                <h:outputLabel for="opt4" value="结束时间" />
                <p:calendar value="#{bean.dateEnd}" mode="popup" pattern="yyyy-MM-dd">
                </p:calendar>
            </h:panelGrid>
        </p:outputPanel>
        &#160;&#160;&#160;

        <p:selectOneMenu id="platformSel" styleClass="queryPlatform" value="#{bean.queryPlatform}">
            <f:selectItems value="#{bean.platformItmes}" />
            <p:ajax update="channelSel serverSel" listener="#{bean.updateChannelItmes}" />
        </p:selectOneMenu>
        &#160;&#160;&#160;

        <p:selectOneMenu id="channelSel" styleClass="queryChannel" value="#{bean.queryChannel}">
            <f:selectItems value="#{bean.channelItmes}" />
            <p:ajax update="serverSel platformSel" listener="#{bean.updateServerItmes}" />
        </p:selectOneMenu>
        &#160;&#160;&#160;

        <p:selectOneMenu id="serverSel" styleClass="queryServer" value="#{bean.queryServer}">
            <f:selectItems value="#{bean.serverItmes}" />
            <p:ajax update="channelSel platformSel" listener="#{bean.selectedServer}" />
        </p:selectOneMenu>
        &#160;&#160;&#160;

        <p:selectOneMenu id="userType" styleClass="queryServer" value="#{bean.queryUserType}">
            <f:selectItems value="#{bean.userTypes}" />
        </p:selectOneMenu>
        &#160;&#160;&#160;

        <p:commandButton value="查询" action="#{bean.search()}" update=":data" ajax="false" />
	</h:form>
	<br />
	
	<!-- 数据展示部分，包含表格和图表 -->
	<h:form id="dform">
		<div class="data" id="data">
            <h:panelGrid columns="1" style="width:100%">
                <div id="basewidth" style="width:95%;height:0; border:0;">
                </div>
            </h:panelGrid>
            <p:panel id="panel" header="活动参与率" style="margin-bottom:10px;">
                <p:selectOneButton value="#{bean.activityType}">
                    <f:selectItems value="#{bean.activityTypes}" />
                    <p:ajax update="panel" listener="#{bean.selectActivityType}" />
                </p:selectOneButton>
                <br /><br />

                <p:remoteCommand name="executeOnOnhide2" update="chart1 dlist1" action="#{bean.handleActivityChange}"/>
                <p:selectCheckboxMenu id="activity1" value="#{bean.selectedActivities}" label="活动" filter="true" filterMatchMode="contains" panelStyle="width:160px" onHide="executeOnOnhide2();">
                    <f:selectItems value="#{bean.activityItmes}" />
                </p:selectCheckboxMenu>
                <p:dataGrid id="chart1" var="c" value="#{bean.activityChart}" columns="1" layout="grid">
                    <p:panel style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <div id="highchartChart1" style="width:100%;height:300px; border:0;">
                                <script type="text/javascript">
                                    generateChart('#{c.jsonStr}', '#{c.jsonType}', '1', 'basewidth');
                                </script>
                            </div>
                        </h:panelGrid>
                    </p:panel>
                </p:dataGrid>

                <p:dataTable id="dlist1" var="l" value="#{bean.activityDatas}" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}" rowsPerPageTemplate="15,30" rows="15" style="text-align:center;">
                    <f:facet name="{Exporters}">
                        <h:commandLink styleClass="exporter">
                            <p:graphicImage url="/resources/images/excel.png" height="25px"/>
                            <p:dataExporter type="xls" target="dlist1" fileName="alivePlayerData-#{pageHelper.getNewDateDetailStr()}" />
                        </h:commandLink>
                    </f:facet>

                    <p:column headerText="日期" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.day}" />
                    </p:column>
                    <p:column headerText="活动类型" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.activityTypeStr}" />
                    </p:column>
                    <p:column headerText="活动名称" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.activityName}" />
                    </p:column>
                    <p:column headerText="参与人数" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.userNum}" />
                    </p:column>
                    <p:column headerText="参与次数" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.joinNum}" />
                    </p:column>
                    <p:column headerText="人均参与次数" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.joinProUserNum}" />
                    </p:column>
                    <p:column headerText="满足条件人数" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{l.okUserNum}" />
                    </p:column>
                    <p:column headerText="参与率" styleClass="column" style="width:80px">
                        <h:outputLabel value="#{pageHelper.double2Percent(l.userJoinRate)}" />
                    </p:column>
                </p:dataTable>
            </p:panel>

            <br />
            <p:separator />
            <p:panel id="pane2" header="人均参与次数" style="margin-bottom:10px;">
                <p:selectOneButton value="#{bean.activityType2}">
                    <f:selectItems value="#{bean.activityTypes}" />
                    <p:ajax update="pane2" listener="#{bean.selectActivityType2}" />
                </p:selectOneButton>
                <br /><br />

                <p:remoteCommand name="executeOnOnhide3" update="chart2" action="#{bean.handleActivityChange2}"/>
                <p:selectCheckboxMenu id="activity2" value="#{bean.selectedActivities2}" label="活动" filter="true" filterMatchMode="contains" panelStyle="width:160px" onHide="executeOnOnhide3();">
                    <f:selectItems value="#{bean.activityItmes}" />
                </p:selectCheckboxMenu>
                <p:dataGrid id="chart2" var="c" value="#{bean.activityChart2}" columns="1" layout="grid">
                    <p:panel style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <div id="highchartChart2" style="width:100%;height:300px; border:0;">
                                <script type="text/javascript">
                                    generateChart('#{c.jsonStr}', '#{c.jsonType}', '2', 'basewidth');
                                </script>
                            </div>
                        </h:panelGrid>
                    </p:panel>
                </p:dataGrid>
            </p:panel>
		</div>
	</h:form>

	<!-- 页脚 -->
	<div class="footer"></div>
</h:body>
</html>